//
//  RTJCheckVersionView.m
//  RuiTaiJinProject
//
//  Created by jayson on 2019/4/4.
//  Copyright © 2019年 leewei. All rights reserved.
//

#import "RTJCheckVersionView.h"
#import "LewPopupViewController.h"

@implementation RTJCheckVersionView

+ (instancetype)defaultViewWithFrame:(CGRect)rect data:(NSDictionary *)data{
    
    
    return [[RTJCheckVersionView alloc]initWithFrame:rect data:data];
    
}

- (id)initWithFrame:(CGRect)frame data:(NSDictionary *)data
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [[NSBundle mainBundle] loadNibNamed:[[self class] description] owner:self options:nil];
      
        _bg_view.frame = frame;
        [self addSubview:_bg_view];
        
        _btn1.layer.cornerRadius = _btn1.height/2;
        _btn1.layer.masksToBounds = YES;
        _btn1.layer.borderColor = [UIColor colorForHex:@"#FE623C"].CGColor;
        _btn1.layer.borderWidth = 1;
        
        _btn2.layer.cornerRadius = _btn2.height/2;
        _btn2.layer.masksToBounds = YES;
        
        _btn3.layer.cornerRadius = _btn3.height/2;
        _btn3.layer.masksToBounds = YES;
        
        NSInteger force_update = [data[@"data"][@"force_update"]integerValue];
        
        if (force_update == 1) {
            
            _btn1.hidden = YES;
            _btn2.hidden = YES;
            
        }else{
            
            _btn3.hidden = YES;
        }
        
        _content.text = [NSString stringWithFormat:@"%@",data[@"data"][@"upgrade"]];
        
    }
    
    return self;
}

- (IBAction)cancel:(id)sender {
    
    if (self.sureClick) {
        
        self.sureClick(NO);
    }
    
    [_parentVC lew_dismissPopupView];
    
}

- (IBAction)sure:(id)sender {
    
    if (self.sureClick) {
        
        self.sureClick(YES);
    }
    
    [_parentVC lew_dismissPopupView];
}

-(void)withSureClick:(CheckVersionBlock)block{
    
    _sureClick = block;
}

@end
